<template>
  <div class="welcom-container">
    <div class="title">
      <h1>{{ nowTime }}</h1>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      nowTime: ''
    }
  },
  created() {
    // 获取当前时间
    this.getNowTime()
  },
  methods: {
    getNowTime() {
      const date = new Date()
      const hour = date.getHours()
      if (hour > 0 && hour < 6) {
        this.nowTime = '欢迎登陆,您起的很早'
      } else if (hour > 6 && hour < 12) {
        this.nowTime = '欢迎登陆,王先生上午好！'
      } else if (hour > 12 && hour < 17) {
        this.nowTime = '欢迎登陆,王先生下午好！'
      } else if (hour > 17 && hour < 24) {
        this.nowTime = '欢迎登陆,王先生晚上好！'
      }
    }
  }
}
</script>

<style lang="less" scoped>
.welcom-container {
  width: 100%;
  height: 100%;
  background: linear-gradient(#a8edea, #fed6e3);

  .title {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 200px;
    line-height: 200px;
    text-align: center;

    h1 {
      font-size: 40px;
    }
  }
}
</style>
